using System.Text;

namespace LuckyLang.AST.Statement;

public class BlockStatement : Statement
{
    public List<AST> Statements { get; set; } // ast => statement

    public BlockStatement(List<AST> statements) => Statements = statements;
    public override string ToString()
    {
        StringBuilder builder = new StringBuilder();
        Statements.ForEach(x => builder.Append(x));
        return builder.ToString();
    }
    public override void Run(ref VariateManager Manager)
    {
        foreach (var VARIABLE in Statements)
        {
            if (VARIABLE is Statement)
            {
                var a = VARIABLE as Statement;
                a.Run(ref Manager);
                if (Manager.Result is not null) 
                {
                    return;
                }
            }
        }
    }
}